package com.recsmile.rpc.bo;

import java.util.concurrent.*;

/**
 * Created by Administrator on 2016/8/3.
 */
public class RpcThreadPool {

    public static ThreadPoolExecutor createExecutor(int threads, int queues){
        return new ThreadPoolExecutor(threads, Integer.MAX_VALUE,
                0, TimeUnit.SECONDS,
                queues == 0 ?new SynchronousQueue<Runnable>()
                : new LinkedBlockingQueue<Runnable>(queues < 0 ? Integer.MAX_VALUE : queues),
                new NamedThreadFactory("RpcThreadPool"), new AbortPolicy("RpcThreadPool"));
    }
}
